<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <h3>bind绑定事件</h3>
    <div id="test" style="cursor: pointer">点击查看名言</div>
    <input id="btntest" type="button" value="点击就不可用了" />
    <hr>
    <button type="button" id="btn1">按钮1</button>
    <button type="button" id="btn2">按钮2</button>
    <button type="button" id="btn3">按钮3</button>
    <button type="button" id="btn4">按钮4</button>

    <script src="js/jquery-3.4.1.js" type="text/javascript" charset="UTF-8"></script>
    <script type="text/javascript">
        //绑定单个事件
        $("#test").bind("click", function () {
            console.log("123");
        });
        //绑定
        $("#btntest").click(function () {
            //禁用按钮
            console.log(this);
            $(this).prop("disabled", true);
        });
        //绑定多个事件
        //1.同时为多个事件绑定同一个函数
        $("#btn1").bind("click mouseout", function () {
            console.log("按钮111111");
        });
        //2.为元素绑定多个事件,并设置对应的函数
        $("#btn2").bind("click", function () {
            console.log("按钮2被点击了");
        }).bind("mouseout", function () {
            console.log("按钮2被移开了");
        });
        //3.为元素绑定多个事件,并设置对应的函数
        $("#btn3").bind({
            "click": function () {
                console.log("按钮3被点击了");
            },
            "mouseout": function () {
                console.log("按钮3移开了")
            }
        });
        //常用绑定
        $("#btn4").click(function () {
            console.log("按钮4被点击了");
        }).mouseout(function () {
            console.log("按钮4移开了")
        });
    </script>
</body>

</html>